package cn.anxingongyou.anxin.service.impl;

import cn.anxingongyou.anxin.entity.JobCategory;
import cn.anxingongyou.anxin.mapper.JobCategoryMapper;
import cn.anxingongyou.anxin.service.JobCategoryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobCategoryServiceImpl implements JobCategoryService {

    private final JobCategoryMapper jobCategoryMapper;
    @Autowired
    public JobCategoryServiceImpl(JobCategoryMapper jobCategoryMapper) {
        this.jobCategoryMapper = jobCategoryMapper;
    }


    @Override
    public int insert(JobCategory jobCategory) {
        return jobCategoryMapper.insertSelective(jobCategory);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return jobCategoryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(JobCategory jobCategory) {
        return jobCategoryMapper.updateByPrimaryKeySelective(jobCategory);
    }

    @Override
    public JobCategory selectOne(JobCategory jobCategory) {
        return jobCategoryMapper.selectOne(jobCategory);
    }

    @Override
    public JobCategory selectOneByPrimaryKey(Long id) {
        return jobCategoryMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<JobCategory> page(int pageNum, int pageSize, JobCategory jobCategory) {
        String orderBy = "id desc";
        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(pageNum,pageSize,orderBy);
        List<JobCategory> list = jobCategoryMapper.select(jobCategory);
        PageInfo<JobCategory> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
